import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:ui_demo/market/stock_list/stock_list_controller.dart';

import '../stock.dart';

class StockListPage extends StatelessWidget {
  StockListController mStockListController = Get.put(StockListController());

  StockListPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder(builder: (StockListController controller) {
      return (controller.mStockLsit.isNotEmpty)
          ? ListView.builder(itemBuilder: (BuildContext context, int index) {
              return StockListItemWidget(controller.mStockLsit[index]);
            })
          : Placeholder();
    });
  }
}

class StockListItemWidget extends StatelessWidget {
  final Stock stock;

  const StockListItemWidget(this.stock, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Expanded(child: Text(stock.mc)),
        Expanded(child: Text(stock.dm)),
        Expanded(child: Text(stock.jys)),
      ],
    );
  }
}
